package t4tools.lepath.util;

import t4tools.lepath.generate.PropertyGetter;

public class PropertyGetterResolver {
	private final static LeClassLoader CLASS_LOADER = new LeClassLoader();

	public static <T> PropertyGetter<T> resolve(T instance) {
		String name = instance.getClass().getName() + "_LePath";
		try {
			@SuppressWarnings("unchecked")
			Class<PropertyGetter<T>> loadClass = (Class<PropertyGetter<T>>) CLASS_LOADER.loadClass(name);
			PropertyGetter<T> newInstance = loadClass.newInstance();
			return newInstance;
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}
}
